<?php
echo '<pre>';
print_r($_FILES);
$msg = '';
$mb = 1;//MB
$allowedSize = $mb*1024*1024;//Bytes
$allowedExtn = array('doc','docx','jpeg');//try with pdf

if(isset($_FILES['avatar']['error'])){
  if($_FILES['avatar']['error']==0){
    if($_FILES['avatar']['size'] > $allowedSize){
      $msg = "1111Please upload file with $mb MB max.";
    } else {
      $fileInfo = pathinfo($_FILES['avatar']['name']);
      print_r($fileInfo);
      if(in_array($fileInfo['extension'],$allowedExtn)) {

      } else {
        $msg = "Please upload file with vaalid extn ".implode(',',$allowedExtn).'.';
      }

    }
  } else {
    $msg = "2222Please upload file with $mb MB max.";
  }
}
echo '<h1><em>'.$msg.'</em></h1>';
?>
<form action="" method="post"
enctype="multipart/form-data">
  Avatar : <input type="file" name="avatar"/><br>
  <input type="submit" value="Upload Data !!" />
</form>
